package com.alu.sg.allstart.allstar.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import com.alu.sg.allstart.R;
import com.alu.sg.allstart.allstar.bean.NamesData;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


/**
 * Created by Alu on 2017/9/14.
 * version 1.0
 */

public class MyAdapter1 extends BaseQuickAdapter<NamesData, BaseViewHolder> {

    public MyAdapter1(@LayoutRes int layoutResId, @Nullable List<NamesData> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, NamesData item) {
        helper.setText(R.id.tv_name, item.getName());
    }

    public int getLetterPosition(String letter) {
        for (int i = 0; i < getData().size(); i++) {
            if (getData().get(i).getPys().substring(0, 1).equals(letter)) {
                return i;
            }
        }
        return -1;
    }
}
